clear all;

load('mig.mat');
 
mig_lb(1:ntheta)=0;
mig_ub(1:ntheta)=0;
z=1.75;
[~,z_index]=min(abs(gridz-z));

for i=1:ntheta
    temp=find(mig_1to2(z_index,:,i)==1);
    if ~isempty(temp)
        mig_lb(i)=min(temp);
        mig_ub(i)=max(temp);
    end
end

index_lb=find(mig_lb~=0);
index_ub=find(mig_ub~=0);

x_highkappa=gridb(mig_lb(index_lb));
y_highkappa=gridtheta(index_lb);

x_highkappa=flip(x_highkappa);
y_highkappa=flip(1-y_highkappa);

save('result_OA9_B.mat','x_highkappa','y_highkappa')